package com.clement.config;

import com.clement.filter.HelloFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

import javax.servlet.Filter;

/**
 * Created by Clement on 2017/4/6.
 */
@Configuration
public class FilterConfig {
    @Bean
    public FilterRegistrationBean helloFilterRegistrationBean() {
        FilterRegistrationBean registrationBean = new FilterRegistrationBean();
        registrationBean.setFilter(helloFilter());
        registrationBean.setName("hello");
        registrationBean.addInitParameter("name", "clement");
        registrationBean.addUrlPatterns("/hello/*");
        registrationBean.setOrder(1);
        return registrationBean;
    }
    @Bean(name = "hello")
    public Filter  helloFilter() {
        return new HelloFilter();
    }

}
